package Gather.Advanced.哈希值.TreeSetLearn.Practice;

public class Student implements Comparable<Student>{
    private String name;
    private int age;
    private int Chinese;
    private int mathematics;
    private int English;

    public Student() {
    }

    public Student(String name, int age, int Chinese, int mathematics, int English) {
        this.name = name;
        this.age = age;
        this.Chinese = Chinese;
        this.mathematics = mathematics;
        this.English = English;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(int age) {
        this.age = age;
    }

    /**
     * 获取
     * @return Chinese
     */
    public int getChinese() {
        return Chinese;
    }

    /**
     * 设置
     * @param Chinese
     */
    public void setChinese(int Chinese) {
        this.Chinese = Chinese;
    }

    /**
     * 获取
     * @return mathematics
     */
    public int getMathematics() {
        return mathematics;
    }

    /**
     * 设置
     * @param mathematics
     */
    public void setMathematics(int mathematics) {
        this.mathematics = mathematics;
    }

    /**
     * 获取
     * @return English
     */
    public int getEnglish() {
        return English;
    }

    /**
     * 设置
     * @param English
     */
    public void setEnglish(int English) {
        this.English = English;
    }

    public String toString() {
        return "Student{name = " + name + ", age = " + age + ", Chinese = " + Chinese + ", mathematics = " + mathematics + ", English = " + English + "}";
    }

    @Override
    public int compareTo(Student o) {
        int score1= o.getChinese()+ o.getEnglish()+o.getMathematics();
        int score2= this.getChinese()+ this.getEnglish()+this.getMathematics();

        //按照总分从高到低输出
        int i=score1-score2;
        //总分一样则按照语文
        i=i==0?this.getChinese()-o.getChinese():i;
        //语文一样则按照数学
        i=i==0?this.getMathematics()-o.getMathematics():i;
        //数学一样则按照英语
        i=i==0?this.getEnglish()-o.getEnglish():i;
        //英语一样则按照年龄
        i=i==0?this.getAge()-o.getAge():i;
        //年龄一样则按照名字首字母
        i=i==0?this.getName().compareTo(o.getName()):i;

        return i;
    }

}
